I want a user to be able to insert a YouTube link within the umbraco UI - this link is to populate the href of an anchor - this anchor will wrap an html image and once clicked on ( in the front end ) fancybox will trigger a pop up with the video inside.
So this all works well and is doing exactly as I want in terms of rendering the image, the href is populating etc the only issue is that when I click on the image on the front end, fancybox triggers but I'm redirected to YouTube to watch the video.
I am wanting to be able to watch the video inside the fancybox.
Are you being "redirected" - or is it maybe the click event getting to the link (this happens if the JavaScript fails)? - Check the Web Inspector Console for JS errors.
Compare the URL you end up at on YouTube to the ones you're generating (you have one in the href, but generate another for FancyBox) - which one do you land on?
If you generate more than one link on the page, you can't use an ID for the video.wrap div - an ID must be unique on a page, so you'd have to change that to a class instead...
Xslt YouTube Video | Fancybox
Hi Guys,
Here is my scenario:
I want a user to be able to insert a YouTube link within the umbraco UI - this link is to populate the href of an anchor - this anchor will wrap an html image and once clicked on ( in the front end ) fancybox will trigger a pop up with the video inside.
Here is my code so far:
<xsl:for-each select="$currentPage">
<div id="video-wrap">
<a href="{videoLink}">
<xsl:if test="videoThumbnail > 0">
<xsl:variable name="img" select="umbraco.library:GetMedia(videoThumbnail, 0)" />
<xsl:variable name="imgPath" select="concat(substring-before($img/umbracoFile,'.'), '.jpg')" />
<img class="" src="/ImageGen.ashx?image={$imgPath}&" alt="{@nodeName}" />
</xsl:if>
</a>
</div>
</xsl:for-each>
So this all works well and is doing exactly as I want in terms of rendering the image, the href is populating etc the only issue is that when I click on the image on the front end, fancybox triggers but I'm redirected to YouTube to watch the video.
I am wanting to be able to watch the video inside the fancybox.
Here is my Jquery code:
$("#video-wrap a").click(function() {
$.fancybox({
'width': 680,
'height': 495,
'href': this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
'type': 'swf',
'wmode': 'transparent',
'allowfullscreen': true
});
});
Any suggetsions?
Jordy
Hi Jordy,
(Got to the post by using only the ID - e.g.: http://our.umbraco.org/forum/developers/xslt/33694
I think you should use the youtube embed URL to not be redirected, e.g.:
/Chriztian
Hi Chriztian,
Ah awesome you managed to get through! I have spoken to admin to get this sorted but anyway on with the issue!
I inserted the embeded url and that didn't work - still redirected me to YouTube.
Is there anything wrong with my Jquery?
Jordy
Hey Jordy,
Are you being "redirected" - or is it maybe the click event getting to the link (this happens if the JavaScript fails)? - Check the Web Inspector Console for JS errors.
Compare the URL you end up at on YouTube to the ones you're generating (you have one in the href, but generate another for FancyBox) - which one do you land on?
If you generate more than one link on the page, you can't use an ID for the video.wrap div - an ID must be unique on a page, so you'd have to change that to a class instead...
/Chriztian
Hey Chriztian,
Right so after a bit more research I have found the solution to my issue - your probing helped though!
The issue was my Jquery and all I had to remove was the href, wmode and allow full screen - must keep the type.
The other issue was the URL - you must have your youtube video link like this: "http://www.youtube.com/v/YOURVIDEOIDHERE"
So my xslt code now looks like this:
<xsl:for-each select="$currentPage">
<div id="video-wrap">
<a href="http://www.youtube.com/v/{videoLink}">
<xsl:if test="videoThumbnail > 0">
<xsl:variable name="img" select="umbraco.library:GetMedia(videoThumbnail, 0)" />
<xsl:variable name="imgPath" select="concat(substring-before($img/umbracoFile,'.'), '.jpg')" />
<img class="" src="/ImageGen.ashx?image={$imgPath}&" alt="{@nodeName}" />
xsl:if>
a>
div>
xsl:for-each>
Also my Jquery now looks like this:
$("#video-wrap a").fancybox({
'width': 680,
'height': 400,
'type': 'swf'
});
All the user has to do in the UI is insert the video ID within the textstring provided and hey presto!
Thanks again for you help Chriztian!
Jordy
is working on a reply...